print0=print
from loguru import logger
import sys

from jili.core.printlog_std import config as config_u
from jili.core.printlog_self import config as config_self
from jili.core.printlog_self import log as logself
level_info={"debug":"DEBUG","info":"INFO","warning":"WARNING","sys":"WARNING","error":"ERROR"}
level_info_h={"debug":logger.debug,"info":logger.info,"warning":logger.warning,"sys":logger.warning,"error":logger.error}
level_infokeys=list(level_info.keys())
level_info_n={"debug":5,"info":4,"warning":3,"sys":2,"error":1}
curr_level_n=4
isdetail=True
isfast_g=False
log_h0=logself.print_imp_detail_no
log_h1=logself.print_imp_detail
def config(logfile="",logfreq="",isscreen=True,level="info",max_logfiles=3,enqueue=False,details=False,isfast=False):
    global isdetail,isfast_g,curr_level_n
    isfast_g=isfast
    isdetail=details
    if level in level_info_n.keys():
        curr_level_n=level_info_n[level]
    if isfast:
        h="config_self"
        config_self(logfile=logfile, logfreq=logfreq, isscreen=isscreen, level=level, max_logfiles=max_logfiles, details=details)
    else:
        h = "config_u"
        config_u(logfile=logfile, logfreq=logfreq, isscreen=isscreen, level=level, max_logfiles=max_logfiles, enqueue=enqueue, details=details)
    print("sys","config print",h,"logfile=",logfile,"logfreq=",logfreq,"isscreen=",isscreen,"level=",level,"max_logfiles=",max_logfiles,"enqueue=",enqueue,"details=",details,"isfast=",isfast)
    # print("sys", h,"isdetail",isdetail,"isfast_g",isfast_g,"curr_level_n",curr_level_n)
def print(*args):
    global curr_level_n,isdetail,isfast_g
    if isfast_g:
        f=args[0]
        if f in level_infokeys:
            n=level_info_n[f]
        else:
            n=4
        if n<=curr_level_n:
            if isdetail:
                filename = sys._getframe().f_back.f_code.co_filename
                funcName = sys._getframe().f_back.f_code.co_name  # 获取调用函数名
                lineNumber = sys._getframe().f_back.f_lineno  # 获取行号
                # h((filename,funcName,lineNumber))
                log_h1(args,filename,funcName,lineNumber)
            else:
                log_h0(args)
    else:
        f=args[0]
        if f in level_infokeys:
            n=level_info_n[f]
            h = level_info_h[f]
            msg=args[1:]
        else:
            n=4
            h=logger.info
            msg=args

        if n<=curr_level_n:
            if isdetail:
                filename = sys._getframe().f_back.f_code.co_filename
                funcName = sys._getframe().f_back.f_code.co_name  # 获取调用函数名
                lineNumber = sys._getframe().f_back.f_lineno  # 获取行号
                # h((filename,funcName,lineNumber))
                h((filename,funcName,lineNumber,msg))
            else:
                h(msg)
print("sys","import printlog.py","isdetail",isdetail,"isfast_g",isfast_g,"curr_level_n",curr_level_n)